import React from 'react';
import { Row, Col } from 'antd';
import { get as getPath } from 'object-path';
/**
 * 表单布局item容器
 * @param rowProps Row
 * @param colProps Col
 * */
const FormContainer = ({ children, rowProps = {}, colProps = {} }) => {
    const childrenArray = React.Children.toArray(children);
    return (
        <Row {...rowProps} gutter={5}>
            {childrenArray.map(item => (
                <Col
                    xs={{ span: 24 }}
                    sm={{ span: 24 }}
                    md={{ span: getPath(item, 'props.vvspan', null) || 12 }}
                    {...colProps}
                    key={item.key}
                >
                    {item}
                </Col>
            ))}
        </Row>
    );
};
const formItemLayout = {
    labelCol: {
        md: { span: 8 },
        xs: { span: 24 },
        sm: { span: 24 }
    },
    wrapperCol: {
        md: { span: 16 },
        xs: { span: 24 },
        sm: { span: 24 }
    }
};

export { FormContainer, formItemLayout };
